﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.ComponentModel.Composition;

using ETRoboConTrakingSystem;

namespace ETRobocon.RaceTraking.GamePresentation
{
    [Export(typeof(IRaceTrackingPresentation))]
    public partial class WindowPresentation : Window, IRaceTrackingPresentation
    {
        public WindowPresentation()
        {
            InitializeComponent();

        }

        public RoundInfo CurrentRoundInfo
        {
            get
            {
                return this.PreMain.CurrentRoundInfo;
            }
        }

        public RunnerInfo CurrentInCourseRunnerInfo
        {
            get
            {
                return this.PreMain.CurrentInCourseRunnerInfo;
            }
        }

        public RunnerInfo CurrentOutCourseRunnerInfo
        {
            get
            {
                return this.PreMain.CurrentOutCourseRunnerInfo;
            }
        }

        public IRunnerStatus InCourseRunnerStatus
        {
            get
            {
                return this.PreMain.InCourseRunner;
            }
        }

        public IRunnerStatus OutCourseRunnerStatus
        {
            get
            {
                return this.PreMain.OutCourseRunner;
            }
        }

        public ITimerCounter MainTimerCounter
        {
            get
            {
                return PreMain.mainTimeConter;
            }
        }


        public void ResetPresentation()
        {
            this.PreMain.ResetPresentation();
        }

        public void ResetTimerCounter()
        {
            this.PreMain.ResetTimerCounter();
        }

        // チーム名表示アニメーション
        public void ShowTeamNameAnimation(String inTeamName, String outTeamName, int turn, int round)
        {
            this.PreNameAnimation.UpdateInformation(inTeamName, outTeamName, turn, round);  // 画面内容の更新
            this.PreNameAnimation.BeginAnimation();                                         // アニメーション開始
        }



        public void UpdateInCourseRunnerTime(string time)
        {
            PreMain.InCourseRunner.CurrentRunner.RunTime = time;
        }

        public void UpdateOutCOurseRunnerTime(string time)
        {
            PreMain.OutCourseRunner.CurrentRunner.RunTime = time;
        }

        public void NotifyCommands(IDictionary<string, string> command)
        {
            // このメソッドが呼ばれた時に、
            // command["course"]=="out"
            // command["drift-turn"]=="course-a" or "course-b"
            // でドリフトターンの走行ルートを指定する予定
            // 表示は、ちょっと気を持たせる感じで、最初の間はどちらが指定されたかわからない感じで
            // その後表示を確定してください。
            string couse="A";
            if (command["drift-turn"] == "course-b")
            {
                couse = "B";
            }
            PreMain.ShowDriftTurnCourse(couse, true);
        }

        private void buttonWindowStyleControl_Click(object sender, RoutedEventArgs e)
        {
            if (this.WindowStyle == System.Windows.WindowStyle.None)
            {
                this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
                buttonWindowStyleControl.Content = "→None";
            }
            else
            {
                this.WindowStyle = System.Windows.WindowStyle.None;
                buttonWindowStyleControl.Content = "";
            }
        }
    }
}
